home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / tcl / tclmotif.1 / tclmotif / tm.1.2 / src / tmCreateWidget.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-03  |  33.8 KB  |  1,142 lines

  1. /* 
  2.  * tmCreateWidget.c --
  3.  *
  4.  *    This module implements the tcl binding to Motif
  5.  *    of the XmCreate... functions
  6.  *
  7.  * Copyright 1993 Jan Newmarch, University of Canberra.
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The author
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  *
  16.  * Copyright 1990-1992 Regents of the University of California.
  17.  * Permission to use, copy, modify, and distribute this
  18.  * software and its documentation for any purpose and without
  19.  * fee is hereby granted, provided that the above copyright
  20.  * notice appear in all copies.  The University of California
  21.  * makes no representations about the suitability of this
  22.  * software for any purpose.  It is provided "as is" without
  23.  * express or implied warranty.
  24.  */
  25.  
  26. #ifndef lint
  27. static char rcsid[] = "$Header: /usrs/tm/RCS/tmPushButton.c,v 1.2 1993/07/14 20:01:43 jan Exp jan $ SPRITE (Berkeley)";
  28. #endif
  29.  
  30. #include "tm.h"
  31. #include "tmFuncs.h"
  32.  
  33. #ifndef MOTIF11
  34. #include <Xm/XmAll.h>
  35. #else
  36. #include <Xm/ArrowB.h>
  37. #include <Xm/BulletinB.h>
  38. #include <Xm/CascadeB.h>
  39. #include <Xm/Command.h>
  40. #include <Xm/DialogS.h>
  41. #include <Xm/DrawingA.h>
  42. #include <Xm/DrawnB.h>
  43. #include <Xm/FileSB.h>
  44. #include <Xm/Form.h>
  45. #include <Xm/Frame.h>
  46. #include <Xm/Label.h>
  47. #include <Xm/List.h>
  48. #include <Xm/MainW.h>
  49. #include <Xm/MessageB.h>
  50. #include <Xm/PanedW.h>
  51. #include <Xm/PushB.h>
  52. #include <Xm/RowColumn.h>
  53. #include <Xm/Scale.h>
  54. #include <Xm/ScrollBar.h>
  55. #include <Xm/ScrolledW.h>
  56. #include <Xm/SelectioB.h>
  57. #include <Xm/Separator.h>
  58. #include <Xm/Text.h>
  59. #include <Xm/TextF.h>
  60. #include <Xm/ToggleB.h>
  61. #endif  /* MOTIF11 */
  62.  
  63. #include <X11/Shell.h>
  64.  
  65. /*
  66.  * this is the list of resources that require the widget rather
  67.  * than its parent for proper conversions from String.
  68.  *
  69.  * This is really quite gross, and a yukky maintainance problem.
  70.  * Besides which, apart from reading oodles of Motif source
  71.  * code, how am I supposed to know what is in this list?
  72.  * Is it dependant on Motif versions?
  73.  *
  74.  * OSF should leap into action and supply a fix for this
  75.  */
  76. static char *dont_use_parent_for_resources[] = {
  77.     "width",
  78.     "height",
  79.     "x",
  80.     "y",
  81.     "marginBottom",
  82.     "marginHeight",
  83.     "marginLeft",
  84.     "marginRight",
  85.     "marginTop",
  86.     "marginWidth",
  87.     "borderWidth",
  88.     "highlightThickness",
  89.     "shadowThickness",
  90.     "sashWidth",
  91.     "sashHeight",
  92.     "labelPixmap",
  93.     "value",    /* need to know if it came from Text, so we can gc it */
  94. /*    "labelType",     this needn't be here, except size calcs go wrong */
  95. };
  96.  
  97. /*
  98.  *--------------------------------------------------------------
  99.  *
  100.  * DontUseParentForResources --
  101.  *
  102.  *    Some widgets use properties of the widget in setting
  103.  *    resource values. For these resources the parent cannot
  104.  *    be used. This function checks on these widgets
  105.  *
  106.  * Results:
  107.  *
  108.  * Side effects:
  109.  *
  110.  *--------------------------------------------------------------
  111.  */
  112.  
  113. static Boolean
  114. DontUseParentForResources(s)
  115.     char *s;
  116. {
  117.     int n;
  118.  
  119.     for (n = 0; n < XtNumber(dont_use_parent_for_resources); n++) {
  120.     if (strcmp(s, dont_use_parent_for_resources[n]) == 0) {
  121.         return True;
  122.     }
  123.     }
  124.     return False;
  125. }
  126.  
  127. /*
  128.  *--------------------------------------------------------------
  129.  *
  130.  * DivideArgs --
  131.  *
  132.  *    Some resources can only be set at create time, so must be
  133.  *    converted *before* the create function. e.g. the
  134.  *    ScrollingPolicy of a ScrolledWindow. Others must be converted
  135.  *    after the widget is created as they use widget values e.g.
  136.  *    the labelPixmap requires fg and bg, and width and all other
  137.  *    dimensions require the UnitType value. This function divides
  138.  *    the resources into before and after sets. Many resources have
  139.  *    no special requirement so are arbitrarily put into the before
  140.  *    list.
  141.  *
  142.  *    This code cannot handle this case: the widget itself
  143.  *    needs to be used, but the value can only be set in the
  144.  *    widget Initialise routine. Fortunately this does not yet
  145.  *    occur, or it will break every Motif binding based on a
  146.  *    string type.
  147.  *
  148.  * Results:
  149.  *
  150.  * Side effects:
  151.  *
  152.  *--------------------------------------------------------------
  153.  */
  154.  
  155. static void
  156. DivideArgs(argv, argc, parent_args, num_parent_args,
  157.                         child_args, num_child_args)
  158.     char *argv[];
  159.     int argc;
  160.     char *parent_args[];
  161.     int *num_parent_args;
  162.     char *child_args[];
  163.     int *num_child_args;
  164. {
  165.     int child, parent, n;
  166.  
  167.     child = parent = 0;
  168.     for (n = 0; n < argc; True) {
  169.     if (DontUseParentForResources(argv[n]+1)) {
  170.         if (child + 3 > TM_MAXARGS) {
  171.         fprintf(stderr, "too many args: %s\n", argv[n]);
  172.         return;
  173.         }
  174.         child_args[child++] = argv[n++];
  175.         child_args[child++] = argv[n++];
  176.     } else {
  177.         if (parent + 3 > TM_MAXARGS) {
  178.         fprintf(stderr, "too many args: %s\n", argv[n]);
  179.         return;
  180.         }
  181.         parent_args[parent++] = argv[n++];
  182.         parent_args[parent++] = argv[n++];
  183.     }
  184.     }
  185.     *num_parent_args = parent;
  186.     *num_child_args = child;
  187. }
  188.  
  189. /*
  190.  *--------------------------------------------------------------
  191.  *
  192.  * Tm_AnyCmd --
  193.  *
  194.  *    This procedure is invoked to process the "ordinary"
  195.  *    widget Tcl commands.  See the
  196.  *    user documentation for details on what it does.
  197.  *
  198.  * Results:
  199.  *    A standard Tcl result.
  200.  *
  201.  * Side effects:
  202.  *    See the user documentation.
  203.  *
  204.  *--------------------------------------------------------------
  205.  */
  206.  
  207. int
  208. Tm_AnyCmd(clientData, interp, argc, argv)
  209.     ClientData clientData;    /* Main window associated with
  210.                  * interpreter. */
  211.     Tcl_Interp *interp;        /* Current interpreter. */
  212.     int argc;            /* Number of arguments. */
  213.     char **argv;        /* Argument strings. */
  214. {
  215.  
  216.     register Tm_Widget *wPtr;
  217.     Widget new, parent;
  218.     char *command = argv[0];
  219.     char *path = argv[1];
  220.     Arg args[TM_MAXARGS];
  221.     int num_args;
  222.     char *parent_argv[TM_MAXARGS], *child_argv[TM_MAXARGS];
  223.     int num_parent_argc, num_child_argc;
  224.     WidgetClass class;
  225.     Tm_WidgetCmdProc widgetCmdProc;
  226.     Boolean managed = False;
  227.     Tcl_CmdInfo parentInfo;
  228.  
  229.     widgetCmdProc = (Tm_WidgetCmdProc) clientData;
  230.  
  231.     parent = Tm_ParentWidgetFromPath (interp, path);
  232.     if (parent == NULL)
  233.     return TCL_ERROR;
  234.  
  235.     if (strcmp(command, xmArrowButton) == 0) {
  236.     class = xmArrowButtonWidgetClass;
  237.     } else
  238.     if (strcmp(command, xmBulletinBoard) == 0) {
  239.     class = xmBulletinBoardWidgetClass;
  240.     } else
  241.     if (strcmp(command, xmCascadeButton) == 0) {
  242.     class = xmCascadeButtonWidgetClass;
  243.     } else
  244.     if (strcmp(command, xmCommand) == 0) {
  245.     class = xmCommandWidgetClass;
  246.     } else
  247.     if (strcmp(command, xmDialogShell) == 0) {
  248.     class = xmDialogShellWidgetClass;
  249.     } else
  250.     if (strcmp(command, xmDrawingArea) == 0) {
  251.     class = xmDrawingAreaWidgetClass;
  252.     } else
  253.     if (strcmp(command, xmDrawnButton) == 0) {
  254.     class = xmDrawnButtonWidgetClass;
  255.     } else
  256.     if (strcmp(command, xmFileSelectionBox) == 0) {
  257.     class = xmFileSelectionBoxWidgetClass;
  258.     } else
  259.     if (strcmp(command, xmForm) == 0) {
  260.     class = xmFormWidgetClass;
  261.     } else
  262.     if (strcmp(command, xmFrame) == 0) {
  263.     class = xmFrameWidgetClass;
  264.     } else
  265.     if (strcmp(command, xmList) == 0) {
  266.     class = xmListWidgetClass;
  267.     } else
  268.     if (strcmp(command, xmLabel) == 0) {
  269.     class = xmLabelWidgetClass;
  270.     } else
  271.     if (strcmp(command, xmMainWindow) == 0) {
  272.     class = xmMainWindowWidgetClass;
  273.     } else
  274.     if (strcmp(command, xmMessageBox) == 0) {
  275.     class = xmMessageBoxWidgetClass;
  276.     } else
  277.     if (strcmp(command, xmPanedWindow) == 0) {
  278.     class = xmPanedWindowWidgetClass;
  279.     } else
  280.     if (strcmp(command, xmPushButton) == 0) {
  281.     class = xmPushButtonWidgetClass;
  282.     } else
  283.     if (strcmp(command, xmScale) == 0) {
  284.     class = xmScaleWidgetClass;
  285.     } else
  286.     if (strcmp(command, xmScrollBar) == 0) {
  287.     class = xmScrollBarWidgetClass;
  288.     } else
  289.     if (strcmp(command, xmScrolledWindow) == 0) {
  290.     class = xmScrolledWindowWidgetClass;
  291.     } else
  292.     if (strcmp(command, xmSelectionBox) == 0) {
  293.     class = xmSelectionBoxWidgetClass;
  294.     } else
  295.     if (strcmp(command, xmSeparator) == 0) {
  296.     class = xmSeparatorWidgetClass;
  297.     } else
  298.     if (strcmp(command, xmText) == 0) {
  299.     class = xmTextWidgetClass;
  300.     } else
  301.     if (strcmp(command, xmTextField) == 0) {
  302.     class = xmTextFieldWidgetClass;
  303.     } else
  304.     if (strcmp(command, xmToggleButton) == 0) {
  305.     class = xmToggleButtonWidgetClass;
  306.     } else
  307.     if (strcmp(command, xmTopLevelShell) == 0) {
  308.     class = topLevelShellWidgetClass;
  309.     } else {
  310.     return TCL_ERROR;
  311.     }
  312.  
  313.     if (argc >= 3 && strcmp(argv[2], "managed") == 0) {
  314.     managed = True;
  315.     argv++;
  316.     argc--;
  317.     }
  318.  
  319.     /* make sure class is initialized before using XtConvertAndStore */
  320.     XtInitializeWidgetClass(class);
  321.  
  322.     DivideArgs(argv + 2, argc - 2, parent_argv, &num_parent_argc,
  323.             child_argv, &num_child_argc);
  324.  
  325.     /* set up for garbage collect of some resource values */
  326.     Tm_InitFreeResourceList((argc - 2)/2);
  327.  
  328.     Tm_SetValues(path, interp, parent, parent, class,
  329.                 parent_argv, num_parent_argc, args, &num_args);
  330.     new = XtCreateWidget (Tm_NameFromPath(path), class, parent, args, num_args);
  331.     Tm_SetValues(path, interp, new, parent, class,
  332.                 child_argv, num_child_argc, args, &num_args);
  333.     XtSetValues(new, args, num_args);
  334.  
  335.     /* collect garbage */
  336.     Tm_FreeResourceList();
  337.     
  338.     if (managed) {
  339.         XtManageChild (new);
  340.     }
  341.  
  342.     wPtr = (Tm_Widget *) XtMalloc (sizeof (Tm_Widget));
  343.     wPtr -> interp = interp;
  344.     wPtr -> widget = new;
  345.     wPtr -> pathName = XtNewString(path);
  346.     wPtr -> parent = Tm_ParentPath(path);
  347.     wPtr -> dropProc = NULL;
  348.  
  349.     Tcl_GetCommandInfo(interp, wPtr->parent, &parentInfo);
  350.     wPtr -> displayInfo = ((Tm_Widget *) parentInfo.clientData)->displayInfo;
  351.  
  352.     Tm_StoreWidgetInfo(path, wPtr, interp);
  353.     XtVaSetValues(new, XmNuserData, wPtr, NULL);
  354.  
  355.     Tcl_CreateCommand (interp, path, widgetCmdProc,
  356.          (ClientData) wPtr, (void (*) ()) NULL);
  357.  
  358.     XtAddCallback(new, XmNdestroyCallback, Tm_DestroyWidgetHandler,
  359.     (XtPointer) wPtr);
  360.             
  361.  
  362.    Tcl_SetResult(interp, wPtr -> pathName, TCL_VOLATILE);
  363.     return TCL_OK;
  364. }
  365.  
  366.  
  367. /*
  368.  *--------------------------------------------------------------
  369.  *
  370.  * CreateChild --
  371.  *
  372.  *    This procedure is used to create tcl commands for 
  373.  *    the following commands that handle widgets with children
  374.  *
  375.  * Results:
  376.  *
  377.  * Side effects:
  378.  *
  379.  *--------------------------------------------------------------
  380.  */
  381.  
  382. static void
  383. CreateChild(interp, path, w, name)
  384.     Tcl_Interp *interp;
  385.     char *path;
  386.     Widget w;
  387.     char *name;
  388. {
  389.     char *subobject_path;
  390.     Tm_Widget *wPtr;
  391.     Tcl_CmdInfo cmdInfo;
  392.  
  393.     subobject_path = XtMalloc(strlen(path) + strlen(name) + 2);
  394.     strcpy(subobject_path, path);
  395.     strcat(subobject_path, ".");
  396.     strcat(subobject_path, name);
  397.  
  398.     Tcl_GetCommandInfo(interp, path, &cmdInfo);
  399.  
  400.     wPtr = (Tm_Widget *) XtMalloc (sizeof (Tm_Widget));
  401.     wPtr -> interp = interp;
  402.     wPtr -> widget = w;
  403.     wPtr -> pathName = subobject_path;
  404.     wPtr -> parent = XtNewString(path);
  405.     wPtr -> dropProc = NULL;
  406.     wPtr -> displayInfo = ((Tm_Widget *) cmdInfo.clientData)->displayInfo;
  407.  
  408.     Tm_StoreWidgetInfo(subobject_path, wPtr, interp);
  409.     XtVaSetValues(w, XmNuserData, wPtr, NULL);
  410.  
  411.     Tcl_CreateCommand (interp, subobject_path, Tm_AnyWidgetCmd,
  412.          (ClientData) wPtr, (void (*) ()) NULL);
  413.         
  414.     XtAddCallback(w, XmNdestroyCallback, Tm_DestroyWidgetHandler,
  415.     (XtPointer) wPtr);
  416. }
  417.  
  418.  
  419. /*
  420.  *--------------------------------------------------------------
  421.  *
  422.  * SelectionBoxCreateChild --
  423.  *
  424.  *    This procedure is used to create tcl commands for 
  425.  *    SelectionBox children
  426.  *
  427.  * Results:
  428.  *
  429.  * Side effects:
  430.  *
  431.  *--------------------------------------------------------------
  432.  */
  433.  
  434. static void
  435. SelectionBoxCreateChild(interp, path, parent, type, name)
  436.     Tcl_Interp *interp;
  437.     char *path;
  438.     Widget parent;
  439.     unsigned char type;
  440.     char *name;
  441. {
  442.     Widget w;
  443.  
  444.     if ((w = XmSelectionBoxGetChild(parent, type)) != NULL) {
  445.     CreateChild(interp, path, w, name);
  446.     }
  447. }
  448.  
  449.  
  450. /*
  451.  *--------------------------------------------------------------
  452.  *
  453.  * FileSelectionBoxCreateChild --
  454.  *
  455.  *    This procedure is used to create tcl commands for 
  456.  *    SelectionBox children
  457.  *
  458.  * Results:
  459.  *
  460.  * Side effects:
  461.  *
  462.  *--------------------------------------------------------------
  463.  */
  464.  
  465. static void
  466. FileSelectionBoxCreateChild(interp, path, parent, type, name)
  467.     Tcl_Interp *interp;
  468.     char *path;
  469.     Widget parent;
  470.     unsigned char type;
  471.     char *name;
  472. {
  473.     Widget w;
  474.  
  475.     if ((w = XmFileSelectionBoxGetChild(parent, type)) != NULL) {
  476.     CreateChild(interp, path, w, name);
  477.     }
  478. }
  479.  
  480.  
  481. /*
  482.  *--------------------------------------------------------------
  483.  *
  484.  * MessageBoxCreateChild --
  485.  *
  486.  *    This procedure is used to create tcl commands for 
  487.  *    MessageBox children
  488.  *
  489.  * Results:
  490.  *
  491.  * Side effects:
  492.  *
  493.  *--------------------------------------------------------------
  494.  */
  495.  
  496. static void
  497. MessageBoxCreateChild(interp, path, parent, type, name)
  498.     Tcl_Interp *interp;
  499.     char *path;
  500.     Widget parent;
  501.     unsigned char type;
  502.     char *name;
  503. {
  504.     Widget w;
  505.  
  506.     if ((w = XmMessageBoxGetChild(parent, type)) != NULL) {
  507.     CreateChild(interp, path, w, name);
  508.     }
  509. }
  510.  
  511. /*
  512.  *--------------------------------------------------------------
  513.  *
  514.  * ScrolledWindowCreateChild --
  515.  *
  516.  *    This procedure is used to create tcl commands for 
  517.  *    ScrolledWindow children
  518.  *
  519.  * Results:
  520.  *
  521.  * Side effects:
  522.  *
  523.  *--------------------------------------------------------------
  524.  */
  525.  
  526. static void
  527. ScrolledWindowCreateChild(interp, path, parent, type, name)
  528.     Tcl_Interp *interp;
  529.     char *path;
  530.     Widget parent;
  531.     String type;
  532.     char *name;
  533. {
  534.     Widget w;
  535.  
  536.     XtVaGetValues(parent, type, &w, NULL);
  537.     if (w != NULL) {
  538.     CreateChild(interp, path, w, name);
  539.     }
  540. }
  541.  
  542. /*
  543.  *--------------------------------------------------------------
  544.  *
  545.  * Tm_HasChildrenCmd --
  546.  *
  547.  *    This procedure is invoked to process the widget commands
  548.  *    that create children, but are not dialogs.
  549.  *    See the
  550.  *    user documentation for details on what it does.
  551.  *    These create a hidden parent, which is the popup shell
  552.  *
  553.  * Results:
  554.  *    A standard Tcl result.
  555.  *
  556.  * Side effects:
  557.  *    See the user documentation.
  558.  *
  559.  *--------------------------------------------------------------
  560.  */
  561.  
  562. int
  563. Tm_HasChildrenCmd(clientData, interp, argc, argv)
  564.     ClientData clientData;    /* Main window associated with
  565.                  * interpreter. */
  566.     Tcl_Interp *interp;        /* Current interpreter. */
  567.     int argc;            /* Number of arguments. */
  568.     char **argv;        /* Argument strings. */
  569. {
  570.     char *command = argv[0];
  571.     char *path = argv[1];
  572.     Widget new;
  573.     Tcl_CmdInfo cmdInfo;
  574.  
  575.     if (Tm_AnyCmd(clientData, interp, argc, argv) == TCL_ERROR)
  576.     return TCL_ERROR;
  577.  
  578.     Tcl_GetCommandInfo(interp, path, &cmdInfo);
  579.  
  580.     new = ((Tm_Widget *) cmdInfo.clientData)->widget;
  581.  
  582.     if (strcmp(command, xmSelectionBox) == 0) {
  583.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_APPLY_BUTTON, "Apply");
  584.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_CANCEL_BUTTON, "Cancel");
  585.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_HELP_BUTTON, "Help");
  586.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_LIST, "ItemsList");
  587.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_LIST_LABEL, "Items");
  588.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_OK_BUTTON, "OK");
  589.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_SELECTION_LABEL, "Selection");
  590.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_SEPARATOR, "Separator");
  591.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_TEXT, "Text");
  592.  
  593.     return TCL_OK;
  594.     }
  595.  
  596.     if (strcmp(command, xmMessageBox) == 0) {
  597.     MessageBoxCreateChild(interp, path, new, XmDIALOG_CANCEL_BUTTON, "Cancel");
  598.     MessageBoxCreateChild(interp, path, new, XmDIALOG_HELP_BUTTON, "Help");
  599.     MessageBoxCreateChild(interp, path, new, XmDIALOG_MESSAGE_LABEL, "Message");
  600.     MessageBoxCreateChild(interp, path, new, XmDIALOG_OK_BUTTON, "OK");
  601.     MessageBoxCreateChild(interp, path, new, XmDIALOG_SEPARATOR, "Separator");
  602.     MessageBoxCreateChild(interp, path, new, XmDIALOG_SYMBOL_LABEL, "Symbol");
  603.  
  604.     return TCL_OK;
  605.     }
  606.  
  607.     if (strcmp(command, xmFileSelectionBox) == 0) {
  608.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_APPLY_BUTTON, "Apply");
  609.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_CANCEL_BUTTON, "Cancel");
  610.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_DIR_LIST, "DirList");
  611.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_DIR_LIST_LABEL, "Dir");
  612.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_FILTER_LABEL, "FilterLabel");
  613.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_FILTER_TEXT, "FilterText");
  614.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_HELP_BUTTON, "Help");
  615.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_LIST, "ItemsList");
  616.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_LIST_LABEL, "Items");
  617.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_OK_BUTTON, "OK");
  618.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_SELECTION_LABEL, "Selection");
  619.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_SEPARATOR, "Separator");
  620.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_TEXT, "Text");
  621.  
  622.     return TCL_OK;
  623.     }
  624.  
  625.     if (strcmp(command, xmScrolledWindow) == 0) {
  626.     ScrolledWindowCreateChild(interp, path, new, XmNhorizontalScrollBar,
  627.                 "HorScrollBar");
  628.     ScrolledWindowCreateChild(interp, path, new, XmNverticalScrollBar,
  629.                 "VertScrollBar");
  630.     ScrolledWindowCreateChild(interp, path, new, XmNclipWindow,
  631.                 "ClipWindow");
  632.  
  633.     return TCL_OK;
  634.     }
  635.  
  636.     return TCL_ERROR;
  637. }
  638.  
  639. /*
  640.  *--------------------------------------------------------------
  641.  *
  642.  * Tm_DialogCmd --
  643.  *
  644.  *    This procedure is invoked to process the "...Dialog"
  645.  *    Tcl commands.  See the
  646.  *    user documentation for details on what it does.
  647.  *    These create a hiddne parent, which is the popup shell
  648.  *
  649.  * Results:
  650.  *    A standard Tcl result.
  651.  *
  652.  * Side effects:
  653.  *    See the user documentation.
  654.  *
  655.  *--------------------------------------------------------------
  656.  */
  657.  
  658. /* ARGSUSED */
  659. int
  660. Tm_DialogCmd(clientData, interp, argc, argv)
  661.     ClientData clientData;    /* Main window associated with
  662.                  * interpreter. */
  663.     Tcl_Interp *interp;        /* Current interpreter. */
  664.     int argc;            /* Number of arguments. */
  665.     char **argv;        /* Argument strings. */
  666. {
  667.  
  668.     register Tm_Widget *wPtr;
  669.     Widget new, parent;
  670.     char *command = argv[0];
  671.     char *path = argv[1];
  672.     char *dialog_path;
  673.     Arg args[TM_MAXARGS];
  674.     int num_args;
  675.     char *parent_argv[TM_MAXARGS], *child_argv[TM_MAXARGS];
  676.     int num_parent_argc, num_child_argc;
  677.     WidgetClass class;
  678.     Boolean managed = False;
  679.     Tcl_CmdInfo parentInfo;
  680.  
  681.     dialog_path = Tm_HiddenParentPath(path);
  682.     if (dialog_path == NULL) {
  683.             Tcl_AppendResult(interp, "Bad window path name \"", path,
  684.                 "\"", (char *) NULL);
  685.         return TCL_ERROR;
  686.     }
  687.  
  688.     parent = Tm_ParentWidgetFromPath (interp, path);
  689.     if (parent == NULL)
  690.     return TCL_ERROR;
  691.  
  692.     if (argc >= 3 && strcmp(argv[2], "managed") == 0) {
  693.         managed = True;
  694.         argv++;
  695.         argc--;
  696.     }
  697.  
  698.     DivideArgs(argv + 2, argc - 2, parent_argv, &num_parent_argc,
  699.                         child_argv, &num_child_argc);
  700.  
  701.     if (strcmp(command, xmBulletinBoardDialog) == 0) {
  702.     class = xmBulletinBoardWidgetClass;
  703.         XtInitializeWidgetClass(class);
  704.         Tm_SetValues(path, interp, parent, parent, class,
  705.                 parent_argv, num_parent_argc, args, &num_args);
  706.     new = XmCreateBulletinBoardDialog (parent,
  707.             Tm_NameFromPath(path), args, num_args);
  708.     } else
  709.     if (strcmp(command, xmFileSelectionDialog) == 0) {
  710.     class = xmFileSelectionBoxWidgetClass;
  711.         XtInitializeWidgetClass(class);
  712.         Tm_SetValues(path, interp, parent, parent, class,
  713.                 parent_argv, num_parent_argc, args, &num_args);
  714.     new = XmCreateFileSelectionDialog (parent,
  715.             Tm_NameFromPath(path), args, num_args);
  716.     } else
  717.     if (strcmp(command, xmFormDialog) == 0) {
  718.     class = xmFormWidgetClass;
  719.         XtInitializeWidgetClass(class);
  720.         Tm_SetValues(path, interp, parent, parent, class,
  721.                 parent_argv, num_parent_argc, args, &num_args);
  722.     new = XmCreateFormDialog (parent,
  723.             Tm_NameFromPath(path), args, num_args);
  724.     } else
  725.     if (strcmp(command, xmErrorDialog) == 0) {
  726.     class = xmMessageBoxWidgetClass;
  727.         XtInitializeWidgetClass(class);
  728.         Tm_SetValues(path, interp, parent, parent, class,
  729.                 parent_argv, num_parent_argc, args, &num_args);
  730.     new = XmCreateErrorDialog (parent, 
  731.             Tm_NameFromPath(path), args, num_args);
  732.     } else 
  733.     if (strcmp(command, xmInformationDialog) == 0) {
  734.     class = xmMessageBoxWidgetClass;
  735.         XtInitializeWidgetClass(class);
  736.         Tm_SetValues(path, interp, parent, parent, class,
  737.                 parent_argv, num_parent_argc, args, &num_args);
  738.     new = XmCreateInformationDialog (parent, 
  739.             Tm_NameFromPath(path), args, num_args);
  740.     } else
  741.     if (strcmp(command, xmMessageDialog) == 0) {
  742.     class = xmMessageBoxWidgetClass;
  743.         XtInitializeWidgetClass(class);
  744.         Tm_SetValues(path, interp, parent, parent, class,
  745.                 parent_argv, num_parent_argc, args, &num_args);
  746.     new = XmCreateMessageDialog (parent, 
  747.             Tm_NameFromPath(path), args, num_args);
  748.     } else
  749.     if (strcmp(command, xmQuestionDialog) == 0) {
  750.     class = xmMessageBoxWidgetClass;
  751.         XtInitializeWidgetClass(class);
  752.         Tm_SetValues(path, interp, parent, parent, class,
  753.                 parent_argv, num_parent_argc, args, &num_args);
  754.     new = XmCreateQuestionDialog (parent, 
  755.             Tm_NameFromPath(path), args, num_args);
  756.     } else
  757.     if (strcmp(command, xmWarningDialog) == 0) {
  758.     class = xmMessageBoxWidgetClass;
  759.         XtInitializeWidgetClass(class);
  760.         Tm_SetValues(path, interp, parent, parent, class,
  761.                 parent_argv, num_parent_argc, args, &num_args);
  762.     new = XmCreateWarningDialog (parent, 
  763.             Tm_NameFromPath(path), args, num_args);
  764.     } else
  765.     if (strcmp(command, xmWorkingDialog) == 0) {
  766.     class = xmMessageBoxWidgetClass;
  767.         XtInitializeWidgetClass(class);
  768.         Tm_SetValues(path, interp, parent, parent, class,
  769.                 parent_argv, num_parent_argc, args, &num_args);
  770.     new = XmCreateWorkingDialog (parent, 
  771.             Tm_NameFromPath(path), args, num_args);
  772.     } else
  773.     if (strcmp(command, xmPromptDialog) == 0) {
  774.     class = xmSelectionBoxWidgetClass;
  775.         XtInitializeWidgetClass(class);
  776.         Tm_SetValues(path, interp, parent, parent, class,
  777.                 parent_argv, num_parent_argc, args, &num_args);
  778.     new = XmCreatePromptDialog (parent, 
  779.             Tm_NameFromPath(path), args, num_args);
  780.     } else
  781.     if (strcmp(command, xmSelectionDialog) == 0) {
  782.     class = xmSelectionBoxWidgetClass;
  783.         XtInitializeWidgetClass(class);
  784.         Tm_SetValues(path, interp, parent, parent, class,
  785.                 parent_argv, num_parent_argc, args, &num_args);
  786.     new = XmCreateSelectionDialog (parent, 
  787.             Tm_NameFromPath(path), args, num_args);
  788.     } else {
  789.     return TCL_ERROR;
  790.     }
  791.  
  792.     Tm_SetValues(path, interp, new, parent, class,
  793.                                 child_argv, num_child_argc, args, &num_args);
  794.     XtSetValues(new, args, num_args);
  795.  
  796.  
  797.     if (managed) {
  798.         XtManageChild (new);
  799.     }
  800.  
  801.     /* set up dialog parent */
  802.  
  803.     wPtr = (Tm_Widget *) XtMalloc (sizeof (Tm_Widget));
  804.     wPtr -> interp = interp;
  805.     wPtr -> widget = XtParent(new);
  806.     wPtr -> pathName = dialog_path;
  807.     wPtr -> parent = Tm_ParentPath(path);
  808.     wPtr -> dropProc = NULL;
  809.  
  810.     Tcl_GetCommandInfo(interp, wPtr->parent, &parentInfo);
  811.     wPtr -> displayInfo = ((Tm_Widget *) parentInfo.clientData)->displayInfo;
  812.  
  813.     Tm_StoreWidgetInfo(dialog_path, wPtr, interp);
  814.     XtVaSetValues(XtParent(new), XmNuserData, wPtr, NULL);
  815.  
  816.     Tcl_CreateCommand (interp, dialog_path, Tm_AnyWidgetCmd,
  817.          (ClientData) wPtr, (void (*) ()) NULL);
  818.  
  819.     XtAddCallback(XtParent(new), XmNdestroyCallback, Tm_DestroyWidgetHandler,
  820.     (XtPointer) wPtr);
  821.  
  822.     /* set up child */
  823.  
  824.     wPtr = (Tm_Widget *) XtMalloc (sizeof (Tm_Widget));
  825.     wPtr -> interp = interp;
  826.     wPtr -> widget = new;
  827.     wPtr -> pathName = XtNewString(path);
  828.     wPtr -> parent = XtNewString(dialog_path);
  829.     wPtr -> dropProc = NULL;
  830.     wPtr -> displayInfo = ((Tm_Widget *) parentInfo.clientData)->displayInfo;
  831.  
  832.     Tm_StoreWidgetInfo(path, wPtr, interp);
  833.     XtVaSetValues(new, XmNuserData, wPtr, NULL);
  834.  
  835.     Tcl_CreateCommand (interp, path, Tm_AnyWidgetCmd,
  836.          (ClientData) wPtr, (void (*) ()) NULL);
  837.  
  838.     XtAddCallback(new, XmNdestroyCallback, Tm_DestroyWidgetHandler,
  839.     (XtPointer) wPtr);
  840.  
  841.     /* create commands for all xmSelectionBox children */
  842.  
  843.     if (class == xmSelectionBoxWidgetClass) {
  844.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_APPLY_BUTTON, "Apply");
  845.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_CANCEL_BUTTON, "Cancel");
  846.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_HELP_BUTTON, "Help");
  847.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_LIST, "ItemsList");
  848.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_LIST_LABEL, "Items");
  849.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_OK_BUTTON, "OK");
  850.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_SELECTION_LABEL, "Selection");
  851.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_SEPARATOR, "Separator");
  852.     SelectionBoxCreateChild(interp, path, new, XmDIALOG_TEXT, "Text");
  853.     } else
  854.  
  855.     if (class == xmMessageBoxWidgetClass) {
  856.     MessageBoxCreateChild(interp, path, new, XmDIALOG_CANCEL_BUTTON, "Cancel");
  857.     MessageBoxCreateChild(interp, path, new, XmDIALOG_HELP_BUTTON, "Help");
  858.     MessageBoxCreateChild(interp, path, new, XmDIALOG_MESSAGE_LABEL, "Message");
  859.     MessageBoxCreateChild(interp, path, new, XmDIALOG_OK_BUTTON, "OK");
  860.     MessageBoxCreateChild(interp, path, new, XmDIALOG_SEPARATOR, "Separator");
  861.     MessageBoxCreateChild(interp, path, new, XmDIALOG_SYMBOL_LABEL, "Symbol");
  862.     } else
  863.  
  864.     if (class == xmFileSelectionBoxWidgetClass) {
  865.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_APPLY_BUTTON, "Apply");
  866.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_CANCEL_BUTTON, "Cancel");
  867.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_DIR_LIST, "DirList");
  868.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_DIR_LIST_LABEL, "Dir");
  869.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_FILTER_LABEL, "FilterLabel");
  870.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_FILTER_TEXT, "FilterText");
  871.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_HELP_BUTTON, "Help");
  872.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_LIST, "ItemsList");
  873.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_LIST_LABEL, "Items");
  874.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_OK_BUTTON, "OK");
  875.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_SELECTION_LABEL, "Selection");
  876.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_SEPARATOR, "Separator");
  877.     FileSelectionBoxCreateChild(interp, path, new, XmDIALOG_TEXT, "Text");
  878.  
  879.     return TCL_OK;
  880.     }
  881.     interp -> result = wPtr -> pathName;
  882.     return TCL_OK;
  883. }
  884.  
  885.  
  886. /*
  887.  *--------------------------------------------------------------
  888.  *
  889.  * Tm_ScrolledCmd --
  890.  *
  891.  *    This procedure is invoked to process the "scrolled..."
  892.  *    Tcl command.  See the
  893.  *    user documentation for details on what it does.
  894.  *    These create a hiddne parent, which is the ScrolledWindow
  895.  *    
  896.  * Results:
  897.  *
  898.  * Side effects:
  899.  *
  900.  *--------------------------------------------------------------
  901.  */
  902.  
  903. /* 
  904. A scrolled widget differs form an ordinary one in that
  905. it is actually two widgets, the scrolled window and
  906. the widget. In this implementation, both must be
  907. visible in the path
  908.     scrolledList <parent>.sw.list
  909. */
  910. int
  911. Tm_ScrolledCmd(clientData, interp, argc, argv)
  912.     ClientData clientData;    /* Main window associated with
  913.                  * interpreter. */
  914.     Tcl_Interp *interp;        /* Current interpreter. */
  915.     int argc;            /* Number of arguments. */
  916.     char **argv;        /* Argument strings. */
  917. {
  918.  
  919.     register Tm_Widget *wPtr;
  920.     Widget new, parent;
  921.     char *command = argv[0];
  922.     char *path = argv[1];
  923.     char *sw_path;
  924.     Arg args[TM_MAXARGS];
  925.     int num_args;
  926.     char *parent_argv[TM_MAXARGS], *child_argv[TM_MAXARGS];
  927.     int num_parent_argc, num_child_argc;
  928.     Tm_WidgetCmdProc widgetCmdProc;
  929.     Boolean managed = False;
  930.     WidgetClass class;
  931.     Tcl_CmdInfo parentInfo;
  932.  
  933.     widgetCmdProc = (Tm_WidgetCmdProc) clientData;
  934.  
  935.     sw_path = Tm_HiddenParentPath(path);
  936.     if (sw_path == NULL) {
  937.             Tcl_AppendResult(interp, "Bad window path name \"", path,
  938.                 "\"", (char *) NULL);
  939.         return TCL_ERROR;
  940.     }
  941.  
  942.     parent = Tm_ParentWidgetFromPath (interp, path);
  943.     if (parent == NULL) {
  944.     XtFree(sw_path);
  945.     return TCL_ERROR;
  946.     }
  947.  
  948.     if (argc >= 3 && strcmp(argv[2], "managed") == 0) {
  949.         managed = True;
  950.         argv++;
  951.         argc--;
  952.     }
  953.  
  954.     DivideArgs(argv + 2, argc - 2, parent_argv, &num_parent_argc,
  955.                         child_argv, &num_child_argc);
  956.  
  957.     if (strcmp(command, xmScrolledList) == 0) {
  958.     class = xmListWidgetClass;
  959.         XtInitializeWidgetClass(class);
  960.         Tm_SetValues(path, interp, parent, parent, class,
  961.                 parent_argv, num_parent_argc, args, &num_args);
  962.         new = XmCreateScrolledList (parent,
  963.             Tm_NameFromPath(path), args, num_args);
  964.     } else
  965.     if (strcmp(command, xmScrolledText) == 0) {
  966.     class = xmTextWidgetClass;
  967.         XtInitializeWidgetClass(class);
  968.         Tm_SetValues(path, interp, parent, parent, class,
  969.                 parent_argv, num_parent_argc, args, &num_args);
  970.         new = XmCreateScrolledText (parent, Tm_NameFromPath(path), args, num_args);
  971.     } else {
  972.     return TCL_ERROR;
  973.     }
  974.  
  975.     Tm_SetValues(path, interp, new, parent, class,
  976.                                 child_argv, num_child_argc, args, &num_args);
  977.     XtSetValues(new, args, num_args);
  978.  
  979.     if (managed) {
  980.         XtManageChild (new);
  981.     }
  982.  
  983.  
  984.     /* set up scrolled window parent */
  985.  
  986.     wPtr = (Tm_Widget *) XtMalloc (sizeof (Tm_Widget));
  987.     wPtr -> interp = interp;
  988.     wPtr -> widget = XtParent(new);
  989.     wPtr -> pathName = sw_path;
  990.     wPtr -> parent = Tm_ParentPath(path);
  991.     wPtr -> dropProc = NULL;
  992.  
  993.     Tcl_GetCommandInfo(interp, wPtr->parent, &parentInfo);
  994.     wPtr -> displayInfo = ((Tm_Widget *) parentInfo.clientData)->displayInfo;
  995.  
  996.     Tm_StoreWidgetInfo(sw_path, wPtr, interp);
  997.     XtVaSetValues(XtParent(new), XmNuserData, wPtr, NULL);
  998.  
  999.     Tcl_CreateCommand (interp, sw_path, Tm_AnyWidgetCmd,
  1000.          (ClientData) wPtr, (void (*) ()) NULL);
  1001.  
  1002.     XtAddCallback(XtParent(new), XmNdestroyCallback, Tm_DestroyWidgetHandler,
  1003.     (XtPointer) wPtr);
  1004.  
  1005.     /* set up list/text widget */
  1006.  
  1007.     wPtr = (Tm_Widget *) XtMalloc (sizeof (Tm_Widget));
  1008.     wPtr -> interp = interp;
  1009.     wPtr -> widget = new;
  1010.     wPtr -> pathName = XtNewString(path);
  1011.     wPtr -> parent  = XtNewString(sw_path);
  1012.     wPtr -> dropProc = NULL;
  1013.     wPtr -> displayInfo = ((Tm_Widget *) parentInfo.clientData)->displayInfo;
  1014.  
  1015.     Tm_StoreWidgetInfo(path, wPtr, interp);
  1016.     XtVaSetValues(new, XmNuserData, wPtr, NULL);
  1017.  
  1018.     Tcl_CreateCommand (interp, path, widgetCmdProc,
  1019.          (ClientData) wPtr, (void (*) ()) NULL);
  1020.  
  1021.     XtAddCallback(new, XmNdestroyCallback, Tm_DestroyWidgetHandler,
  1022.     (XtPointer) wPtr);
  1023.  
  1024.     interp -> result = wPtr -> pathName;
  1025.     return TCL_OK;
  1026. }
  1027.  
  1028. /*
  1029.  *--------------------------------------------------------------
  1030.  *
  1031.  * Tm_RowColumnCmd --
  1032.  *
  1033.  *    This procedure is invoked to process the "rowColumn",
  1034.  *    "menuBar" and "pulldownMenu" Tcl commands.  See the
  1035.  *    user documentation for details on what it does.
  1036.  *    RowCol has lots of convenience creation functions
  1037.  *
  1038.  * Results:
  1039.  *    A standard Tcl result.
  1040.  *
  1041.  * Side effects:
  1042.  *    See the user documentation.
  1043.  *
  1044.  *--------------------------------------------------------------
  1045.  */
  1046.  
  1047. /* ARGSUSED */
  1048. int
  1049. Tm_RowColumnCmd(clientData, interp, argc, argv)
  1050.     ClientData clientData;    /* Main window associated with
  1051.                  * interpreter. */
  1052.     Tcl_Interp *interp;        /* Current interpreter. */
  1053.     int argc;            /* Number of arguments. */
  1054.     char **argv;        /* Argument strings. */
  1055. {
  1056.     char *command = argv[0];
  1057.     register Tm_Widget *wPtr;
  1058.     Widget new, parent;
  1059.     char *path = argv[1];
  1060.     Arg args[TM_MAXARGS];
  1061.     int num_args;
  1062.     char *parent_argv[TM_MAXARGS], *child_argv[TM_MAXARGS];
  1063.     int num_parent_argc, num_child_argc;
  1064.     Boolean managed = False;
  1065.     Tcl_CmdInfo parentInfo;
  1066.     Tm_WidgetCmdProc widgetCmdProc;
  1067.  
  1068.     widgetCmdProc = (Tm_WidgetCmdProc) clientData;
  1069.  
  1070.     parent = Tm_ParentWidgetFromPath (interp, path);
  1071.     if (parent == NULL)
  1072.     return TCL_ERROR;
  1073.  
  1074.     if (argc >= 3 && strcmp(argv[2], "managed") == 0) {
  1075.         managed = True;
  1076.         argv++;
  1077.         argc--;
  1078.     }
  1079.  
  1080.     /* make sure class is initialized before using XtConvertAndStore */
  1081.     XtInitializeWidgetClass(xmRowColumnWidgetClass);
  1082.  
  1083.     DivideArgs(argv + 2, argc - 2, parent_argv, &num_parent_argc,
  1084.                         child_argv, &num_child_argc);
  1085.  
  1086.     Tm_SetValues(path, interp, parent, parent, xmRowColumnWidgetClass,
  1087.                 parent_argv, num_parent_argc, args, &num_args);
  1088.     if (strcmp(command, xmRowColumn) == 0) {
  1089.         new = XmCreateRowColumn (parent,
  1090.             Tm_NameFromPath(path), args, num_args);
  1091.     } else 
  1092.     if (strcmp(command, xmMenuBar) == 0) {
  1093.     new = XmCreateSimpleMenuBar(parent, 
  1094.             Tm_NameFromPath(path), args, num_args);
  1095.     } else 
  1096.     if (strcmp(command, xmOptionMenu) == 0) {
  1097.     new = XmCreateOptionMenu(parent, 
  1098.             Tm_NameFromPath(path), args, num_args);
  1099.     } else 
  1100.     if (strcmp(command, xmPopupMenu) == 0) {
  1101.     new = XmCreatePopupMenu(parent, 
  1102.             Tm_NameFromPath(path), args, num_args);
  1103.     } else 
  1104.     if (strcmp(command, xmPulldownMenu) == 0) {
  1105.     new = XmCreatePulldownMenu(parent, 
  1106.             Tm_NameFromPath(path), args, num_args);
  1107.     } else {
  1108.     sprintf(interp->result, "Unknown xmRowColumn creation command %s\n",
  1109.             command);
  1110.     return TCL_ERROR;
  1111.     }
  1112.     Tm_SetValues(path, interp, new, parent, xmRowColumnWidgetClass,
  1113.                                 child_argv, num_child_argc, args, &num_args);
  1114.     XtSetValues(new, args, num_args);
  1115.  
  1116.     if (managed) {
  1117.         XtManageChild (new);
  1118.     }
  1119.  
  1120.     wPtr = (Tm_Widget *) XtMalloc (sizeof (Tm_Widget));
  1121.     wPtr -> interp = interp;
  1122.     wPtr -> widget = new;
  1123.     wPtr -> pathName = XtNewString(path);
  1124.     wPtr -> parent = Tm_ParentPath(path);
  1125.     wPtr -> dropProc = NULL;
  1126.  
  1127.     Tcl_GetCommandInfo(interp, wPtr->parent, &parentInfo);
  1128.     wPtr -> displayInfo = ((Tm_Widget *) parentInfo.clientData)->displayInfo;
  1129.  
  1130.     Tm_StoreWidgetInfo(path, wPtr, interp);
  1131.     XtVaSetValues(new, XmNuserData, wPtr, NULL);
  1132.  
  1133.     Tcl_CreateCommand (interp, path, widgetCmdProc,
  1134.          (ClientData) wPtr, (void (*) ()) NULL);
  1135.  
  1136.     XtAddCallback(new, XmNdestroyCallback, Tm_DestroyWidgetHandler,
  1137.     (XtPointer) wPtr);
  1138.  
  1139.     interp -> result = wPtr -> pathName;
  1140.     return TCL_OK;
  1141. }
  1142.